﻿#region using

using System.ComponentModel;
using System.Windows.Forms;

#endregion using

namespace T4_Eind_programma
{
    public partial class VulbatchScherm : Form
    {
        #region Variable

        private Mengbatch mijnMengbatch;

        #endregion Variable

        #region Constructor

        public VulbatchScherm(Mengbatch mijnMengbatch)
        {
            this.mijnMengbatch = mijnMengbatch;
            InitializeComponent();
            mijnMengbatch.VulbatchList.ListChanged += VulbatchList_ListChanged;
            RefreshListView();
        }

        #endregion Constructor

        #region Events

        private void VulbatchList_ListChanged(object sender, ListChangedEventArgs e)
        {
            RefreshListView();
        }

        #endregion Events

        private void RefreshListView()
        {
            listViewVulBatch.Items.Clear();
            foreach (Vulbatch batch in mijnMengbatch.VulbatchList)
            {
                ListViewItem lv = new ListViewItem(mijnMengbatch.Nummer.ToString());
                lv.SubItems.Add(batch.Nummer.ToString());
                lv.SubItems.Add(batch.AantalVaten.ToString());
                lv.SubItems.Add(batch.Klaar.ToString());
                lv.SubItems.Add(batch.Doeltank.Naam);
                lv.SubItems.Add(batch.GevuldeVaten.ToString());
                lv.SubItems.Add(batch.RestVaten.ToString());
                string apparaten = "";
                foreach (string item in batch.GebruikteApparaten)
                {
                    apparaten += item + "/";
                }
                lv.SubItems.Add(apparaten);
                listViewVulBatch.Items.Add(lv);
            }
            try
            {
                listViewVulBatch.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            }
            catch (System.Exception)
            {
            }
        }
    }
}